package treeStudy;

import java.util.ArrayList;
import java.util.List;

public class IsSymmetric {

    private List<Integer> res = new ArrayList<>();

    /**
     * LeetCode T101
     * @param args
     */
    public static void main(String[] args) {

    }

    public boolean isSymmetric(TreeNode root) {
        if (root == null){
            return true;
        }
        return dfs(root.left, root.right);

    }

    public boolean dfs(TreeNode leftRoot, TreeNode rightRoot){
        if (leftRoot == null && rightRoot == null){
            return true;
        }
        if (leftRoot != null && rightRoot != null){
            return (leftRoot.val == rightRoot.val) && dfs(leftRoot.left,rightRoot.right) && dfs(leftRoot.right, rightRoot.left);
        }
        return false;
    }


}
